package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by balau on 3/9/14.
 *
 *
 */
public class Library {

    private final PrintStream out;
    private List<String> books;
    private Map<String,String> checkedOut;

    public Library(PrintStream out, Map<String,String> checkedOut) {
        this.out = out;
        this.books = new ArrayList<> ();
        books.add("To Kill A Mockingbird");
        books.add("Anna Karenina");
        books.add("Ender's Game");
        books.add("Brave New World");
        this.checkedOut = checkedOut;
    }

    public String listBooks() {
        String bookList = "";
        for (String book: books) {
            bookList = bookList + book + "\n";
        }
        return bookList;
    }

    public void printBooks() {
        out.println("These are the books in the library: ");
        out.println(listBooks());
    }

    public void checkoutBook(String bookName, String userName) {
        books.remove(bookName);
        checkedOut.put(bookName, userName);
        out.println("Successfully checked out book.");
    }

}
